export default async function catchError(ctx, next) {
  try {
    await next();
    if (ctx.body) return;
    ctx.status = 200;
    ctx.body = {
      msg: 'success',
      code: '0',
    };
  } catch (error) {
    if (error.name === 'SequelizeDatabaseError') {
      ctx.status = 500;
      ctx.body = {
        msg: error.message,
        code: '1',
      };
    }
  }
}